<?xml version='1.0' encoding="us-ascii"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">

    <xsl:template match="abstract">
        <fo:block xsl:use-attribute-sets="abstract.properties">
            <xsl:attribute name="start-indent">
                <xsl:choose>
                    <!-- Set abstract indent for all but components -->
                    <xsl:when test="parent::book">0pt</xsl:when>
                    <xsl:when test="parent::chapter">0pt</xsl:when>
                    <xsl:when test="parent::appendix">0pt</xsl:when>
                    <xsl:when test="parent::article">0pt</xsl:when>
                    <xsl:when test="parent::section and count(ancestor::section)&lt;2">0pt</xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$body.start.indent" />
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <xsl:if test="@id">
                <xsl:attribute name="id">
                    <xsl:value-of select="@id" />
                </xsl:attribute>
            </xsl:if>
            <xsl:if test="$formal.abstract != '0'">
                <xsl:element name="fo:block" use-attribute-sets="abstract.title.properties">
                    <xsl:apply-templates select="self::abstract" mode="title.markup" />
                </xsl:element>
            </xsl:if>
            <xsl:apply-templates />
        </fo:block>
    </xsl:template>

    <xsl:template match="formalpara">
        <xsl:call-template name="para-spacer">
            <xsl:with-param name="content">
                <xsl:apply-templates />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template match="para">
        <xsl:call-template name="para-spacer">
            <xsl:with-param name="content">
                <xsl:call-template name="anchor" />
                <xsl:apply-templates />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>


    <xsl:template match="formalpara/para">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="simpara">
        <xsl:call-template name="para-spacer">
            <xsl:with-param name="content">
                <xsl:if test="@id">
                    <xsl:attribute name="id">
                        <xsl:value-of select="@id" />
                    </xsl:attribute>
                </xsl:if>
                <xsl:apply-templates />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="para-spacer">
        <xsl:param name="content" />
        <xsl:choose>
            <xsl:when
                test="ancestor::glossentry|ancestor::varlistentry|parent::warning|parent::note|parent::tip|parent::important|parent::caution">
                <xsl:element name="fo:block" use-attribute-sets="compact.para.spacing">
                    <xsl:if test="@id">
                        <xsl:attribute name="id">
                            <xsl:value-of select="@id" />
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:copy-of select="$content" />
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="fo:block" use-attribute-sets="normal.para.spacing">
                    <xsl:if test="@id">
                        <xsl:attribute name="id">
                            <xsl:value-of select="@id" />
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:copy-of select="$content" />
                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>
